﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Raspare;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace SharedMobilePlatform
{
	public partial class MainPage : ContentPage
	{
	    private string raspNamn;

		public MainPage ()
		{
			InitializeComponent ();

            if (Application.Current.Properties.ContainsKey("Name") && Application.Current.Properties["Name"] != null)
            {
                raspNamn = Application.Current.Properties["Name"] as string;
            }

            //Debug
            //Name = "Myggdräpe";
            //raspNamn = "Myggdräpe";

		    if (!String.IsNullOrWhiteSpace(raspNamn))
		    {
                Navigation.PushAsync(new SelectPage(raspNamn));
		    }
		}
        
	    async void GetCharactersButtonClicked(object sender, EventArgs args)
	    {

            Button button = (Button)sender;
	        if (!String.IsNullOrWhiteSpace(raspNamn))
	        {
                Application.Current.Properties["Name"] = raspNamn;
                await Navigation.PushAsync(new SelectPage(raspNamn));
	        }
	    }

        void OnRaspnameChanged(object sender, PropertyChangedEventArgs args)
        {
            Entry text = (Entry) sender;
            raspNamn = text.Text;
        }
	}
}
